#pragma once

#include "Framework/CommonHead.h"
#include "Widgets/Widget.h"
#include "VerticalPositionerWidget.m.h"


//the widget with a positioner
RCLASS()
class WHENGINE_API  RVerticalPositionerWidget :public RWidget
{
    ROBJECT
public:          

    float Spacing=10;

    //if collapsed, stop paint and arrange children
    TWidgetAttribute<bool> Collapsed = false;

    // virtual void AddSubWidget( RWidgetPtr InWidget) override;

    float GetContentPresentLength()
    {
        return PresentLength;
    }

    virtual void CalculatePresentPositionAndSize() override;
    virtual void CalculateChildrenPresentPositionAndSize() override;
    virtual float CalculateContentHeight() override;
    virtual void PaintSubWidgets(uint16_t&  InZOrder) override;
    //determine children's position
    //automatically invoke once per frame 
    //you can invoke this to calculate Content present length
    void ArrangeChildren();

    TDelegate<void> OnChildrenArranged;
    
    virtual SColor GetDebugBoxColor() override { return SColor::Blue; };
protected:
    float PresentLength=0;    
    bool bChildrenArranged=false;



};